
package com.zcsy.manage.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zcsy.manage.model.base.CellHouse;
import com.zcsy.manage.model.base.CellInfo;
import com.zcsy.manage.model.base.OwnerHouse;
import com.zcsy.manage.persistence.base.OwnerHouseDao;
import com.zcsy.manage.service.base.IOwnerHouseService;
import com.zcsy.manage.service.system.impl.SystemComService;

/**
 * @Title: OwnerHouseServiceImpl.java
 * @Package： com.zcsy.manage.service.base.impl 
 * @Description: 业主房屋接口实现类
 * @author huangls 1449700087@qq.com
 * @date 2016年7月29日
 * @version 1.0
 * @see JDK1.7.0_75
 * @Copyright: 2016 武汉恒数利通技术有限公司 All rights reserved.
 */
@Service
public class OwnerHouseServiceImpl  extends SystemComService implements IOwnerHouseService {
	
	@Autowired
    private OwnerHouseDao ownerHouseDao;
	
	@Override
    public int insert(OwnerHouse ownerHouse) {
        return ownerHouseDao.insert(ownerHouse);
    }
	
	@Override
    public int updateOwnerHouse(OwnerHouse ownerHouse) {
		OwnerHouse oldOwnerHouse = ownerHouseDao.selectByPrimaryKey(ownerHouse.getId());
		
		oldOwnerHouse.setCellId(ownerHouse.getCellId());
		oldOwnerHouse.setHouseId(ownerHouse.getHouseId());
		oldOwnerHouse.setOwnerId(ownerHouse.getOwnerId());
		oldOwnerHouse.setState(ownerHouse.getState());
		
        return ownerHouseDao.updateOwnerHouse(oldOwnerHouse);
    }

    @Override
    public int deleteHouuseByHouseId(String houseId) {
        return ownerHouseDao.deleteHouuseByHouseId(houseId);
    }

    @Override
    public OwnerHouse selectByPrimaryKey(String id) {
        return ownerHouseDao.selectByPrimaryKey(id);
    }
    
    @Override
    public List<CellInfo> getCellInfoListByAreaId(Integer areaId) {
        return ownerHouseDao.getCellInfoListByAreaId(areaId);
    }
    
    @Override
    public List<CellInfo> getCellInfoListByOwnerId(String ownerId) {
        return ownerHouseDao.getCellInfoListByOwnerId(ownerId);
    }
    
    @Override
    public List<CellHouse> getCellHouseListByOwnerId(String ownerId) {
        return ownerHouseDao.getCellHouseListByOwnerId(ownerId);
    }
    
    @Override
    public List<CellHouse> getCurrentCellHouse(String ownerId, String cellId) {
        return ownerHouseDao.getCurrentCellHouse(ownerId, cellId);
    }

    @Override
    public List<String> getUserAccountByCellId(String cellId){
        return ownerHouseDao.getUserAccountByCellId(cellId);
    }

    @Override
    public OwnerHouse selectByKeyword(String cellId,String houseId,String ownerId) {
        OwnerHouse ownerHouse = new OwnerHouse();
        
        ownerHouse.setCellId(cellId);
        ownerHouse.setHouseId(houseId);
        ownerHouse.setOwnerId(ownerId);
        
        OwnerHouse house = ownerHouseDao.selectByKeyword(ownerHouse);
        
        return house;
    }

	@Override
	public Integer selectByHouseIds(String[] houseIDs) {
		return ownerHouseDao.selectByHouseIds(houseIDs);
	}
	
	/**
     * 根据房屋id和业主id获取新申请和正常状态的房屋信息
     * @Method: getOwnerHouserByHouseAndOwner
     * @author hubing
     * @date 2016年9月18日
     */
	@Override
	public List<OwnerHouse> getOwnerHouserByHouseAndOwner(String houserId, String ownerId){
        return ownerHouseDao.getOwnerHouserByHouseAndOwner(houserId, ownerId);
    }
}
